package top.lileix.mybatis.generator.x.domain;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

/**
 * 表对象
 * 
 * @author lilei
 *
 */
public class Table {
    // 表名
    private String tableName;
    // 模型名称
    private String modeName;
    // 备注
    private String remark;

   
    public String getRemark() {
	return remark;
    }

    public void setRemark(String remark) {
	this.remark = remark;
    }

    public String getModeName() {
	return modeName;
    }

    public void setModeName(String modeName) {
	this.modeName = modeName;
    }

    // 字段
    private Set<Column> columns;

    public String getTableName() {
	return tableName;
    }

    public Set<Column> getColumns() {
	return columns;
    }

    public void setTableName(String tableName) {
	this.tableName = tableName;
    }

    public void setColumns(Set<Column> columns) {
	this.columns = columns;
    }

    @Override
    public String toString() {
	final int maxLen = 10;
	return String.format(
		"{\"tableName\":\"%s\",\"modeName\":\"%s\",\"remark\":\"%s\",\"columns\":\"%s\"}",
		tableName, modeName, remark, columns != null ? toString(columns, maxLen) : null);
    }

    private String toString(Collection<?> collection, int maxLen) {
	StringBuilder builder = new StringBuilder();
	builder.append("[");
	int i = 0;
	for (Iterator<?> iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) {
	    if (i > 0)
		builder.append(", ");
	    builder.append(iterator.next());
	}
	builder.append("]");
	return builder.toString();
    }

   

}
